package com.pjhouse.core.customer.persistence.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.pjhouse.core.common.persistence.IBatisBaseRepository;
import com.pjhouse.core.customer.domain.CustomerDTO;
import com.pjhouse.core.customer.persistence.CustomerRepository;

@Repository("customerRepository")
public class CustomerRepositoryImpl extends IBatisBaseRepository implements CustomerRepository {

	@Override
	public long insert(CustomerDTO customer) {
		return (Long)super.insert("PJ.CUSTOMER.insert", customer);
	}

	@Override
	public boolean updateStatus(long id, int status) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("id", id);
		param.put("status", status);
		return super.update("PJ.CUSTOMER.updateStatus", param) == 1;
	}

	@Override
	public CustomerDTO queryById(long id) {
		return (CustomerDTO) super.queryForObject("PJ.CUSTOMER.findById", id);
	}

}
